package skewreduce.framework;

import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import skewreduce.framework.physical.PhysicalOp;


public class SchedulerAdaptor implements SchedulerEventHandler {
	protected static Log LOG = LogFactory.getLog("Scheduler");
	
    public void handle(SchedulerEvent e) {
        PhysicalOp op = e.getSource();
        switch ( e.getEventType() ) {
            case COMPLETE:
                handleCompletion(op);
                break;
            case FAILED:
                handleFailed(op);
                break;
            case KILLED:
                handleKilled(op);
                break;
            case RUNNING_SLOW:
                handleRunningSlow(op);
                break;
            case ERROR:
                handleError(op,((SchedulerEvent.Error)e).getCause());
                break;
            default: /* discard */
            	;
        }
    }

    public void handleCompletion(PhysicalOp op) {
    }
    public void handleFailed(PhysicalOp op) {
    }
    public void handleKilled(PhysicalOp op) {
    }
    public void handleRunningSlow(PhysicalOp op) {
    }
    public void handleError(PhysicalOp op,Throwable ex) {
    }

    public Set<PhysicalOp> reoptimize(Set<PhysicalOp> ops) {
        return ops;
    }
}
